﻿

using System;

namespace IFramework
{   
    public class Json
    {
        private static IJsonHelper s_JsonHelper;
        public static void SetJsonHelper(IJsonHelper jsonHelper)
        {
            s_JsonHelper = jsonHelper;
        }
        private static void CheckNull()
        {
            if (s_JsonHelper==null)
            {
                SetJsonHelper(new DefaultJsonHelper());
            }
        }
       
        
        public static string ToJson(object obj)
        {
            CheckNull();
            return s_JsonHelper.ToJson(obj);
        }
        public static T ToObject<T>(string json)
        {
            CheckNull();
            return s_JsonHelper.ToObject<T>(json);
        }
        public static object ToObject(Type objectType, string json)
        {
            CheckNull();
            return s_JsonHelper.ToObject(objectType, json);
        }

    }
}
